import React, { useState } from 'react'
import { useEffect } from 'react'

export default function Cat() {
    let [x, setX] = useState(100)
    let [y, setY] = useState(100)
    x += 110
    y += 110
    function move(e){
        setX(e.clientX)
        setY(e.clientY)
    }
    useEffect(()=>{
        window.addEventListener('mousemove',move)
        return ()=>{
            // 卸载移除自定义事件
            window.removeEventListener('mousemove',move)
        }

    },[])
    return (
        <div className="base cat" style={{left:x,top:y}}>Cat</div>
    )
}
